<?php
    defined('_JEXEC') or die(); 
    JHTML::_('behavior.tooltip'); 
    $listOrder    = @$this->lists['order'];
    $listDirn    = @$this->lists['order_Dir'];
?>
<style>
    #tbl_filter{
        margin: 0 ; padding: 0 ;
    }
    #tbl_filter td{
        padding: 3px;
    }
    #tbl_filter input, #tbl_filter img {
        float: left;
        margin: 0 5px 0 0;
        width: auto;
    }
    .outlet-list, .outlet-list-extra { display: none; }   
    table.adminlist tbody tr td { padding: 8px 8px; }
    table.adminlist thead th { padding: 8px; } 
</style>
<link rel="stylesheet" type="text/css" href="<?php echo JURI::root(); ?>js/multiselect/jquery.multiselect.css" />
<link rel="stylesheet" type="text/css" href="<?php echo JURI::root(); ?>js/multiselect/jquery-ui.css" />
<script type="text/javascript" src="<?php echo JURI::root();?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo JURI::root();?>js/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?php echo JURI::root();?>js/multiselect/jquery.multiselect.js"></script>

<script language="javascript" type="text/javascript">
    function submitform(pressbutton){
        var form = document.adminForm ;
        //alert(pressbutton)
        if (pressbutton)
        {
            form.task.value=pressbutton ;
        }
        if ((pressbutton=='send_redemp_notice_email')||(pressbutton=='send_redemp_pick_up_notice')){
              form.controller.value="reports" ;
        }
        form.submit();
    }
    jQuery(function(){
        jQuery("#extra_status").attr({"multiple":false, "size":1}); 
    });
</script>
<div class="col width-100">    
    
        <div id="editcell">
            <form action="<?php echo JRoute::_("index.php?option=com_wrd&controller=reports")?>" method="post" name="filterform" >
                <table style='margin-bottom:5px' id="tbl_filter">
                    <tbody>
                        <tr>
                            <td align="left" valign="bottom" style="border-right: 1px solid #d0d0d0;">
                                <table >
                                    <tr valign="top">
                                        <td valign="top" width='35px'>From</td>        
                                        <td valign="top" width='150px'>
                                            <?php
                                                echo JHTML::_ ( 'calendar', ($this->pr['date_from'] != '') ? $this->pr['date_from'] : date('Y-m-d', mktime(0, 0, 0, date('m'), 1, date('Y'))), 'date_from', 'date_from', '%Y-%m-%d');
                                            ?>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td width='35px'>To</td>        
                                        <td width='150px'>
                                            <?php
                                                echo JHTML::_ ( 'calendar', ($this->pr['date_to'] != '') ? $this->pr['date_to'] : date('Y-m-d', time()), 'date_to', 'date_to', '%Y-%m-%d');
                                            ?>
                                        </td>
                                      
                                    </tr>
                                </table>
                            </td>
                            <td align="left" valign="middle" style="border-right: 1px solid #d0d0d0;">
                                <table >
                                    <tr>
                                        <td>Status: </td>
                                        <td style="width: 230px;">
                                            <?php echo $this->lists['extra_status'] ; ?>                                            
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left ;">
                                            <input type="submit" name="summary" onclick="document.getElementById('submitViewExcel').value = 'submitViewExcel';  document.getElementById('task').value = 'membershipclub';" value="Summary" />
                                            <input type="submit" name="detail" onclick="document.getElementById('submitViewExcel').value = 'submitViewExcel';  document.getElementById('task').value = 'membershipclubdetail';" value="Detail" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                                                        
                            <td align="left" valign="bottom">
                                <table >
                                    <tr>
                                        <td>
                                             Top: 
                                        </td>
                                        <td>
                                            Choose: 
                                            <select name="topDisplaySelect" id="topDisplaySelect">
                                                <option value="10">10</option>
                                                <option value="20">20</option>
                                                <option value="50">50</option>
                                                <option value="100">100</option>
                                                <option value="">All</option>
                                            </select>&nbsp;or type&nbsp;
                                            <input name="topDisplaytbx" id="topDisplaytbx" type="text" style="width: 60px; float: none;" />
                                        </td>
                                    </tr>
                                    <tr>
                                        
                                        <td>
                                            &nbsp;
                                        </td>
                                        <td style="text-align: left ;padding: 10px 0 0;">                                            
                                            <input type="submit" id="exportexcelsummary" name="exportexcelsummary" onclick="document.getElementById('task').value = 'exmembershipclub'" value="Export summary excel" />
                                            <input type="submit" id="exportexceldetail" name="exportexceldetail" onclick="document.getElementById('task').value = 'exmembershipclubdetail'" value="Export detail excel" />
                                        </td>
                                    </tr>
                                </table>
                            </td>                            
                        </tr>
                    </tbody>
                </table>
                <input type="hidden" name="controller" value="reports" />
                <input type="hidden" name="option" value="com_wrd" />
                <input type="hidden" name="submitViewExcel" id="submitViewExcel" value="" />
                <input type="hidden" name="task" id="task" value="" />
            </form>    
            <br />
            <form id="adminForm" action="<?php echo JRoute::_("index.php?option=com_wrd&controller=reports")?>" method="post" name="adminForm">
                <table width="100%" class="adminlist">
                    <thead>
                        <tr>                             
                            <th nowrap="nowrap">
                                 Member - Recruitment
                            </th>
                            <?php 
                                $newJoinMember = '';
                                $memberTotal = '';
                                $monthlyActiveMember = '';
                                $monthlyInactiveMember = '';
                                $unConfirmedMember = '';
                                //$unConfirmedMemberPrevMonth = 984;
                                
                                foreach($this->items as $key => $item):
                                
                                    echo '<th nowrap="nowrap">'.$key.'</th>';
                                    $newJoinMember .= '<td nowrap="nowrap" align="center">'.$item['new_join_member'].'</td>';
                                    $memberTotal .= '<td nowrap="nowrap" align="center">'.number_format($item['member_total'], 0, '.', '.').'</td>';
                                    $monthlyActiveMember .= '<td nowrap="nowrap" align="center">'.number_format($item['active_member'], 0, '.', '.').'</td>';
                                    $monthlyInactiveMember .= '<td nowrap="nowrap" align="center">'.number_format(($item['member_total']-$item['active_member']), 0, '.', '.').'</td>';
                                    //$unConfirmedMemberPrevMonth = number_format(($unConfirmedMemberPrevMonth + $item['new_join_member'] - $item['pick_up_member']), 0, '.', '.');
                                    $unConfirmedMember .= '<td nowrap="nowrap" align="center">'.number_format(($item['member_total'] - $item['pick_up_member']), 0, '.', '.').'</td>';
                                    
                                endforeach;
                            ?>               
                        </tr>
                    </thead>
                    <tbody>
                            <tr>                             
                                <td nowrap="nowrap" style="width: 180px;">
                                     New Join Member
                                </td>          
                                <?php 
                                    echo $newJoinMember;
                                ?>
                            </tr>
                            <tr class="row1">                             
                                <td nowrap="nowrap">
                                     PTD Member Total
                                </td>          
                                <?php 
                                    echo $memberTotal;
                                ?>
                            </tr>
                            <tr>                             
                                <td nowrap="nowrap">
                                     No. of Monthly Active Member
                                </td>          
                                <?php 
                                    echo $monthlyActiveMember;
                                ?>
                            </tr>
                            <tr class="row1">                             
                                <td nowrap="nowrap">
                                     No. of Monthly Inactive Member
                                </td>          
                                <?php 
                                    echo $monthlyInactiveMember;
                                ?>
                            </tr>
                            <tr>                             
                                <td nowrap="nowrap">
                                    No. of Un-confirmed Member
                                </td>          
                                <?php 
                                    echo $unConfirmedMember;
                                ?>
                            </tr>
                    </tbody>    
                </table>
                <input type="hidden" name="controller" value="reports" />
                <input type="hidden" name="option" value="com_wrd" />
                <input type="hidden" name="task" value="membershipclub" />
                <input type="hidden" name="boxchecked" value="0" />
                <?php echo JHTML::_( 'form.token' ); ?>
            </form>
        </div>
        
</div>
<?php 
    //$this->downloadFileExcel();
?>
